This tour will work a little better in interactive mode, so it'll be better if you get IPython notebook installed and running. You can start it from a terminal by running
jupyter notebook
In [ ]:
import pandas as pd
print("Hi! This is a cell. Press the ▶ button above to run it")
You can also run a cell with Ctrl+Enter or Shift+Enter. Experiment a bit with that.
In [ ]:
pd.read_csv(
After the first time, you should see this:
After the second time:
After the fourth time, a big help box should pop up at the bottom of the screen, with the full documentation for the read_csv
function:
I find this amazingly useful. I think of this as "the more confused I am, the more times I should press Shift+Tab". Nothing bad will happen if you tab complete 12 times.
In [ ]:
pd.r
You should see this:
Writing code in the notebook is pretty normal.
In [ ]:
def print_10_nums():
for i in range(10):
print(i, end=' ')
In [ ]:
print_10_nums()
As of the latest stable version, the notebook autosaves. You should use the latest stable version. Really.
Jupyter has all kinds of magic functions. Here's an example of comparing sum()
with a list comprehension to a generator comprehension using the %time
magic.
In [ ]:
%time sum([x for x in range(100000)])
In [ ]:
%time sum(x for x in range(100000))
In [ ]:
%quickref
In [ ]:
%%perl
$_ = "whoa, python!";
s/python/perl/;
print
In [ ]:
!cat foo.py
In [ ]:
import foo
foo.some_function()
In [ ]:
foo.some_function()
In [ ]:
%load_ext autoreload
%autoreload 1
In [ ]:
import foo
foo.some_function()
In [ ]:
foo.some_function()
In [ ]:
import pylab as plt
%matplotlib inline
plt.plot(range(10),range(10))
That's it for now!